var status;
var newhandMap = 910000000;
var SteppedSnailMap = 915010101;
var changeJobMap = 910000000;
var text;
var freetimes = 0;
var basemeso = 300000;
var needmeso = 0;
var icon = "#fEffect/CharacterEff.img/1082565/2/0#";

function start() {
    status = -1;
    action(1, 0, 0)
}

function action(f, g, i) {
    if (f == -1) {
        cm.dispose()
    } else {
        if (f == 0 && status == 0) {
            cm.dispose();
            return
        }
        if (f == 1) {
            status++
        } else {
            cm.dispose();
            return
        }
        if (status == 0) {
            var b = cm.getBossLog("星星副本");
            text = "#e#r\t\t\t狂虐 羊羊 星星 进行曲#k#n\r\n";
            text += "#d　　　当日已进入副本：[ #r" + b + "#d ] - 玩家「 #r#h # 」#d#k#n\r\n\r\n";
            text += "#d#e-副本介绍\r\n#k#n";
            text += "#d\t\t\t\t副本时间限制 #r10#d 分钟\r\n";
            text += "\t经验按照时间递增 [但若积累过多羊羊会崩溃游戏]\r\n";
            text += "\t尽量多消灭羊羊-星星与魔方的数量在于消灭小绵羊\r\n";
            text += "\t经验值的信息:▲采用递增方式星星经验互不耽误▲\r\n";
            text += "\t星星魔方信息:▲每只都必出星星　魔方属于概率▲\r\n";
            text += "#r\t\t\t　福利丰富玩家不容错过\r\n#k#n";
            text += "　#i1142813# #i5062009# #i5062002# #i3015034# #i2340000# #i2614017# #i2531000# #i1402014#\r\n";
            cm.sendOkS(text);
            if (cm.getMapId() != newhandMap) {
                cm.dispose();
                return
            }
        } else {
            if (status == 1) {
                var b = cm.getBossLog("星星副本");
                needmeso = getNeedMeso(b);
                text = "#d\r\n\r\nAre you ready? \r\n\r\n一起狂虐羊羊吧！经验 星星 魔方 让你爽到不要不要的#k#n\r\n\r\n";
                text += "#r羊羊土豪门票：50\r\n羊羊金币门票：300000000\r\n#b下回金币门票：" + needmeso + "#k\r\n\r\n";
                text += "#L0#" + icon + " 金币参与 " + icon + "#l　\t\t　#L1#" + icon + " 土豪参与 " + icon + "#l\r\n";
                cm.askYesNo(text)
            } else {
                if (status == 2) {
                    if (i == 0) {
                        var d = true;
                        if (cm.getPlayer().getLevel() < 150) {
                            cm.sendOk("死亡可不会怜悯你的，150级后再来吧！");
                            d = false
                        } else {
                            if (cm.getParty() != null) {
                                cm.sendOk("请退出当前队伍");
                                d = false
                            } else {
                                if (cm.getMeso() < needmeso) {
                                    cm.sendOk("您的金币不足#r" + needmeso + "#k，无法再次挑战");
                                    d = false
                                }
                            }
                        }
                        if (d) {
                            var e = cm.getEventManager("xxevent");
                            if (e == null) {
                                cm.sendOk("副本出错，请联系GM");
                                cm.dispose();
                                return
                            }
                            var h = e.newInstance(cm.getPlayer().getName());
                            var c = h.createInstanceMapS(SteppedSnailMap);
                            var j = cm.getPlayer();
                            var a = e.getMapFactory().getMap(changeJobMap);
                            h.registerPlayer(j);
                            j.changeMap(c, c.getPortal(0));
                            h.startEventTimer(60000 * 10);
                            cm.setBossLog("星星副本");
                            cm.gainMeso(-needmeso);
                            cm.worldSpouseMessage(36, "[羊羊提示] : 玩家[" + cm.getPlayer().getName() + "] 参与了 羊羊进行曲 ※ 星星 魔方 享不停 ※ - 加油吧");
                            cm.dispose()
                        } else {
                            cm.dispose();
                            return
                        }
                    } else {
                        if (i == 1) {
                            var d = true;
                            if (cm.getPlayer().getLevel() < 150) {
                                cm.sendOk("死亡可不会怜悯你的，150级后再来吧！");
                                d = false
                            } else {
                                if (cm.getParty() != null) {
                                    cm.sendOk("请退出当前队伍");
                                    d = false
                                } else {
                                    if (cm.getHyPay(1) < 50) {
                                        cm.sendOk("您的余额小于 #r50#k 无法再次挑战");
                                        d = false
                                    }
                                }
                            }
                            if (d) {
                                var e = cm.getEventManager("xxevent");
                                if (e == null) {
                                    cm.sendOk("副本出错，请联系GM");
                                    cm.dispose();
                                    return
                                }
                                var h = e.newInstance(cm.getPlayer().getName());
                                var c = h.createInstanceMapS(SteppedSnailMap);
                                var j = cm.getPlayer();
                                var a = e.getMapFactory().getMap(changeJobMap);
                                h.registerPlayer(j);
                                j.changeMap(c, c.getPortal(0));
                                h.startEventTimer(60000 * 10);
                                cm.setBossLog("星星副本");
                                cm.addHyPay(50);
                                cm.worldMessageYellow("[羊羊副本] : 玩家[" + cm.getPlayer().getName() + "] 参与了 羊羊进行曲 ※ 星星 魔方 享不停 ※ - 加油吧");
                                cm.dispose()
                            } else {
                                cm.dispose();
                                return
                            }
                        }
                    }
                }
            }
        }
    }
}

function getNeedMeso(d) {
    if (d < freetimes) {
        return 0
    } else {
        d -= freetimes - 1
    }
    var a = 0;
    var c = new Array();
    for (var b = 0; b < d; b++) {
        if (c.length < 2) {
            a += basemeso
        } else {
            a = c[b - 2] + c[b - 1]
        }
        c.push(a)
    }
    return a
}
var status = -1;